package com.fs.jzzn.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.fs.jzzn.pojo.Invoice;
/**
 * @author TiddlerCJ
 */
public interface InvoiceRepository extends JpaRepository<Invoice,String>, JpaSpecificationExecutor<Invoice>{
	
	//根据合同编号查找对应的子项工程发票及合同对应的发票
	@Query(value="SELECT p.* FROM p_invoice p WHERE p.p_no IN (SELECT t.p_no FROM p_project t WHERE t.contract_no=:contractNo) or p.p_no =:contractNo ORDER BY bill_kind,bill_date asc",nativeQuery=true)
	List<Invoice> findBycontractNo(@Param("contractNo") String contractNo);
}
